package main

import "fmt"

/**
2.4.1. 元组赋值
元组赋值是另一种形式的赋值语句，它允许同时更新多个变量的值
*/
func main() {
	var x, y int
	x = 1
	y = 0
	x, y = y, x
	fmt.Println("x = ", x, " y = ", y)

	a := []int{1, 2, 3, 4, 5}
	a[1], a[2] = a[3], a[4]
	fmt.Println(a)

	fmt.Println(gcd(1, 90))

	fmt.Println(fib(10))

}

func gcd(x, y int) int {
	if y != 0 {
		x, y = y, x%y
	}
	return x
}

func fib(n int) int {
	x, y := 0, 1
	for i := 0; i < n; i++ {
		x, y = y, x+y
	}
	return x
}
